From edd8164fb14b1cdd0985eeb1ae3e7307c08ae8e6 Mon Sep 17 00:00:00 2001 From: Eusgor <100363036+Eusgor@users.noreply.github.com> Date: Fri, 30 May 2025 02:01:48 +0600 Subject: [PATCH] [PATCH] src: fix possible dereference of null pointer There is a CHECK_NOT_NULL check before dereferencing node_env on line 710 in the "if" block, but there is no CHECK_NOT_NULL check before dereferencing node_env on line 721. Maybe it makes sense to put CHECK_NOT_NULL right after calling the Environment::GetCurrent function. PR-URL: https://github.com/nodejs/node/pull/58459 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Chengzhong Wu Gbp-Pq: Topic sec Gbp-Pq: Name 17-fix-possible-dereference-of-null-pointer.patch --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index d8a203ba4..34b2c1e5e 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -693,9 +693,9 @@ void napi_module_register_by_symbol(v8::Local exports, napi_addon_register_func init, int32_t module_api_version) { node::Environment* node_env = node::Environment::GetCurrent(context); + CHECK_NOT_NULL(node_env); std::string module_filename = ""; if (init == nullptr) { - CHECK_NOT_NULL(node_env); node_env->ThrowError("Module has no declared entry point."); return; } -- 2.30.2